import React from 'react'
import { createBehavior, createResource } from '@designable/core'
import { DnFC } from '@designable/react'
import { createVoidFieldSchema } from '../Field'
import { AllSchemas } from '../../schemas'
import { AllLocales } from '../../locales'
import { QRCode as CustomQRCode } from '../../customComponents'

export const QRCode: DnFC<React.ComponentProps<typeof CustomQRCode>> =
  CustomQRCode

QRCode.Behavior = createBehavior({
  name: 'QRCode',
  extends: ['Field'],
  selector: (node) => node.props['x-component'] === 'QRCode',
  designerProps: {
    propsSchema: createVoidFieldSchema(AllSchemas.QRCode),
  },
  designerLocales: AllLocales.QRCode,
})

QRCode.Resource = createResource({
  icon: 'Qrcode',
  elements: [
    {
      componentName: 'Field',
      props: {
        type: 'void',
        title: 'QRCode',
        'x-component': 'QRCode',
        'x-component-props': {
          value: 'https://example.com',
          size: 128,
        },
      },
    },
  ],
})
